package com.spring.shops.dao;

import com.spring.shops.model.entity.TzSysUserRole;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface TzSysUserRoleMapper {
    int deleteByPrimaryKey(Long id);

    int insert(TzSysUserRole record);

    int insertSelective(TzSysUserRole record);

    TzSysUserRole selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(TzSysUserRole record);

    int updateByPrimaryKey(TzSysUserRole record);

    /**
     * 根据用户id删除对应的用户角色表中的数据
     * @param userId
     * @return
     */
    @Delete("delete from yami_shops.tz_sys_user_role where user_id=#{userId}")
    int deleteByUserId(Long userId);

    /**
     * 根据用户id获取用户所属的角色id列表
     * @param userId
     * @return
     */
    @Select("select role_id from yami_shops.tz_sys_user_role where user_id=#{userId}")
    List<Long> selectByUserId(Long userId);
}